<?php namespace Home\Controller;

use Hdphp\Controller\Controller;

class RegController extends Controller{
	
	
	public function index(){
		if(IS_POST){
			$code = Q('post.captcha');
			$code = strtolower($code);
			$sessioncode = strtolower($_SESSION['code']);
			if($code != $sessioncode){
				View::error('验证码错误');
				return;
			}
			$username = Q('post.username');
			$password = Q('post.pwd','','md5');
			$data = array(
				'account'=>$username,
				'pwd'=>$password,
			);
			Db::table('user')->insert($data);
			$url = U('Login/index');
			$str = <<<str
			<script>
			alert('注册成功！')
			location.href="$url"
			</script>
str;
			echo $str;
		}
		View::make();
	}
}

 ?>